import { _decorator } from 'cc';
import { Utitls } from './Common/Utils';
import { EnemyController, EnemyFrameAnimType, EnemyFrameInfo } from './Logic/Enemy/EnemyController';
const { ccclass, property } = _decorator;

@ccclass('Enemy')
export class Enemy extends EnemyController {

    onChildInit() {
        this._speed = 0.75;
        let index = Utitls.Random(0, 2);
        if (index == 1) {
            this.hp = 10;
            this.hurt = 15;
            let info:EnemyFrameInfo = new EnemyFrameInfo();
            info.animType = EnemyFrameAnimType.Idle;
            info.startIndex = 0;
            info.endIndex = 11;
            info.frameName = "Idle_";
            info.rootPath = "Frame/Enemy/Enemy1/Idle";
            info.speed = 0.04;
            info.isLoop = true;
            this.frameInfoList.push(info);

            info = new EnemyFrameInfo();
            info.animType = EnemyFrameAnimType.Run;
            info.startIndex = 0;
            info.endIndex = 17;
            info.speed = 0.04;
            info.isLoop = true;
            info.frameName = "Walking_";
            info.rootPath = "Frame/Enemy/Enemy1/Running";
            this.frameInfoList.push(info);

            info = new EnemyFrameInfo();
            info.animType = EnemyFrameAnimType.Attack;
            info.startIndex = 0;
            info.endIndex = 11;
            info.speed = 0.02;
            info.isLoop = false;
            info.frameName = "Attacking_";
            info.rootPath = "Frame/Enemy/Enemy1/Shooting";
            this.frameInfoList.push(info);

            info = new EnemyFrameInfo();
            info.animType = EnemyFrameAnimType.Die;
            info.startIndex = 0;
            info.endIndex = 14;
            info.speed = 0.02;
            info.isLoop = false;
            info.frameName = "Dying_";
            info.rootPath = "Frame/Enemy/Enemy1/Dying";
            this.frameInfoList.push(info);
        }
        else{
            this.hp = 10;
            this.hurt = 20;
            let info:EnemyFrameInfo = new EnemyFrameInfo();
            info.animType = EnemyFrameAnimType.Idle;
            info.startIndex = 0;
            info.endIndex = 11;
            info.speed = 0.04;
            info.isLoop = true;
            info.frameName = "Idle_";
            info.rootPath = "Frame/Enemy/Enemy2/Idle";
            this.frameInfoList.push(info);

            info = new EnemyFrameInfo();
            info.animType = EnemyFrameAnimType.Run;
            info.startIndex = 0;
            info.endIndex = 11;
            info.speed = 0.04;
            info.isLoop = true;
            info.frameName = "Walking_";
            info.rootPath = "Frame/Enemy/Enemy2/Running";
            this.frameInfoList.push(info);

            info = new EnemyFrameInfo();
            info.animType = EnemyFrameAnimType.Attack;
            info.startIndex = 0;
            info.endIndex = 11;
            info.speed = 0.02;
            info.isLoop = false;
            info.frameName = "Attacking_";
            info.rootPath = "Frame/Enemy/Enemy2/Shooting";
            this.frameInfoList.push(info);

            info = new EnemyFrameInfo();
            info.animType = EnemyFrameAnimType.Die;
            info.startIndex = 0;
            info.endIndex = 14;
            info.speed = 0.02;
            info.isLoop = false;
            info.frameName = "Dying_";
            info.rootPath = "Frame/Enemy/Enemy2/Dying";
            this.frameInfoList.push(info);
        }
        
    }
}


